<?php

function connect () {
	$host = 'sql.free.fr';
	$mysql_login = 'bourtaillar';
	include ('mysql_passwd.php');
	$db = 'bourtaillar';
   
	$conn = mysql_connect($host, $mysql_login, $mysql_passwd) or die ("Erreur lors de la connexion au serveur MySQL. ".mysql_error());
	mysql_select_db ($db, $conn) or die ("Erreur lors de la selection de la base");
	
	return $conn;
}

function query ($query) {
	connect ();
	
	$res = mysql_query ($query) or die("Erreur sur la requete: ".mysql_error());
	
	if (! isSelect($query))
		close ();
	
	return $res;
}

function isSelect ($query) {
	return stristr (substr ($query, 0, 6), "SELECT");
}
   
function close () {
	mysql_close ();
}

?>
